package com.atguigu.exam;

/**
 * @author xbd
 * @create 2021-05-25 18:01
 */
public class ReverTest {
    public static void main(String[] args) {
        ReverTest r1 = new ReverTest();
        System.out.println(r1.reverseString("abcdefg", 2, 5));
    }
    public String reverseString(String str,int start,int end){
        char[] c = str.toCharArray();
        return reverseArrays(c,start,end);
    }
    public String reverseArrays(char[] c,int start,int end){
        for (int i = start, j = end; i < j; i++,j--) {
            char temp = c[i];
            c[i] = c[j];
            c[j] = temp;
        }
        return new String(c);
    }
}
